package insight.google.game.era.core;

import com.google.apphosting.api.ApiProxy;
import com.google.apphosting.api.ApiProxy.Delegate;


import insight.google.game.era.core.exception.InsightException;
import insight.google.game.era.data.Player;

/**
 * Implementation class need to have roomList<Room> and userList<User> and dataVersion data.
 * 
 * for publicData(), it sends latest room list<Room> and user list<User> data with data version to each online user 
 * in this game center.(Client must record this data version to pass it to server in each server request 
 * for consistence check. Also check whether there is any user disconnected. if user is disconnected 
 * for 3 times, then just automatically logout him.
 * 
 * @author MMC
 *
 */
public interface IGameCenter extends IServerClientData {
	public boolean addUser(Player player) throws InsightException;
	public boolean removePlayer(Player player) throws InsightException;
	
	/**
	 * Check whether Player is already login, call google login if Player id not login.
	 * then make Player instance and call addPlayer(Player) to add Player to game center. 
	 * @return
	 * @throws InsightException
	 */
	public void login() throws InsightException;
	//public Player doLogin() throws InsightException;
	
	public String onLoad();
	/**
	 * Actually this method is called by Player.logout() method.
	 * call removePlayer(player) if Player in in game center, then call google logout to redirect to game welcome page.
	 * @param player
	 * @return
	 * @throws InsightException
	 */
	public boolean logout(String jsComponentId) throws InsightException;
	//public boolean doLogout(Player player) throws InsightException;
	

}
